package com.test.service;

import com.test.dao.AddressDao;
import com.test.domain.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class AddressService {

    private final AddressDao addressDao;

    @Autowired
    public AddressService(AddressDao addressDao) {
        this.addressDao = addressDao;
    }

    public void insertAddress(Address address){
        addressDao.insertAddress(address);
    }

    public List<Address> getAddressListByPhoneNumber(String customerPhoneNumber){
        return addressDao.getAddressListByPhoneNumber(customerPhoneNumber);
    }

    public void updateName(String addressNumber, String name) {
        addressDao.updateNameByAddressNumber(addressNumber,name);
    }

    public void updatePhoneNumber(String addressNumber, String phoneNumber) {
        addressDao.updatePhoneNumberByAddressNumber(addressNumber, phoneNumber);
    }

    public void updateAddress(String addressNumber, String address) {
        addressDao.updateAddressByAddressNumber(addressNumber, address);
    }

    public void deleteAddress(String addressNumber){
        addressDao.deleteAddressByAddressNumber(addressNumber);
    }

}
